class Student {
    int id;
    String name;

    public Student(int id, String name) {
        this.id = id;
        this.name = name;
    }

    @Override
    public String toString() {              //重写toStrong便于我们打印
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }
}

public class text2 {
    public static void main(String[] args) {
        Student student = new Student(10,"zhangsan");
        String str = String.valueOf(student);
        System.out.println(str);//输出Student{id=10, name='zhangsan'}
    }
}
